<div class="search">
<span>
年级：
<select name="grade">
<option>-----请选择-----</option>
</select>
</span>
<span>
专业：
<select name="major">
<option>-----请选择-----</option>
</select>
</span>
<span>
班级：
<select name="class">
<option>-----请选择-----</option>
</select>
</span>
<span>
学年：<input style="width:100px" type="text" name="year"/></span>
    <hr>
<label style="display:inline" for="termup">
	<input style="margin:0px" type="radio" name="term" id="termup" value="up" checked/>上半学期
</label>
<label style="display:inline" for="termdown">
	<input style="margin:0px" type="radio" name="term" id="termdown" value="down"/>下半学期
</label>
<button style="margin-top:-10px;" class="btn btn-primary" id="submit_search">检索</button>
</div>
<hr>
<div id="count_result"></div>
<script>
	var byclass=new PureAjax();
	var grade=document.getElementsByName("grade")[0];
	var major=document.getElementsByName("major")[0];
	var iclass=document.getElementsByName("class")[0];
	var submit=document.getElementById("submit_search");
	var year1=document.getElementsByName("year")[0];
	var term=document.getElementsByName("term");
	var year=(new Date()).getFullYear();
	var j;
	var opt;
	var term1=term[0].value;
	term[0].onclick=function(){
		term1=term[0].value;
	};
	term[1].onclick=function(){
		term1=term[1].value;
	};
	for(j=0;j<5;j++){
		opt=document.createElement("option");
		opt.value=year-j;
		opt.innerHTML=(year-j)+"级";
		grade.appendChild(opt);
	}
	j=0;
	byclass.post({
		dataType:"json",
		data:{},
		async:true,
		url:URL+"Request/getMajorList",
		success:function(data){
			var length=data.length;
			for(j=0;j<length;j++){
				opt=document.createElement("option");
				opt.value=data[j].code;
				opt.innerHTML=data[j].name;
				major.appendChild(opt);
			}
		}
	});
	j=0;
	major.onchange=function(){
		byclass.post({
			dataType:"json",
			data:{getmajor:major.value},
			async:true,
			url:URL+"Request/getClassList",
			success:function(data){
				var length=data.length;
				iclass.innerHTML="";
				for(j=0;j<length;j++){
					opt=document.createElement("option");
					opt.value=data[j].code;
					opt.innerHTML=data[j].name;
					iclass.appendChild(opt);
				}
			}
		});
	}
	submit.onclick=function(){
		byclass.post({
			dataType:"html",
			data:{getgrade:grade.value,
				getmajor:major.value,
				getclass:iclass.value,
				getyear:year1.value,
				mode:term1
				},
			url:URL+"Count/countBK",
			success:function(data){
				document.getElementById("count_result").innerHTML=data;
			}
			
		});
	}
</script>
